﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;

namespace MAF.Common
{
    public class BaseQueryVo
    {
        private string _Table = null;

        private string _Id = null;
        private string _Name = null;
        private string _ParentId = null;
        private string _Ids = null;
        private PageInfo _Page = null;

        private string _StringA = null;
        private string _StringB = null;
        private string _StringC = null;
        private DateTime? _DateTimeA = null;
        private DateTime? _DateTimeB = null;

        public string Table
        {
            get { return _Table; }
            set { _Table = value; }
        }

        public string Id
        {
            get { return _Id; }
            set { _Id = value; }
        }

        public string Ids
        {
            get { return _Ids; }
            set { _Ids = value; }
        }

        public string ParentId
        {
            get { return _ParentId; }
            set { _ParentId = value; }
        }

        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        public PageInfo Page
        {
            get { return _Page; }
            set { _Page = value; }
        }

        public string StringA
        {
            get { return _StringA; }
            set { _StringA = value; }
        }

        public string StringB
        {
            get { return _StringB; }
            set { _StringB = value; }
        }

        public string StringC
        {
            get { return _StringC; }
            set { _StringC = value; }
        }

        public DateTime? DateTimeA
        {
            get { return _DateTimeA; }
            set { _DateTimeA = value; }
        }

        public DateTime? DateTimeB
        {
            get { return _DateTimeB; }
            set { _DateTimeB = value; }
        }

        public static BaseQueryVo Parse(NameValueCollection nvc)
        {
            BaseQueryVo vo = new BaseQueryVo();
            if (null != nvc)
            {
                vo.Name = nvc["Name"];
                vo.ParentId = nvc["ParentId"];
                vo.Ids = nvc["Ids"];
                vo.StringA = nvc["StringA"];
                vo.StringB = nvc["StringB"];
                vo.StringC = nvc["StringC"];

                string page = nvc["Page"];
                string size = nvc["PageSize"];

                //if (null != page || null != size)
                //{
                //    vo.Page = new PageInfo(DB.Count(vo)
                //                           , Utils.TryParse<int>(size)
                //                           , Utils.TryParse<int>(page)
                //                          );
                //}
            }
            return vo;
        }
    }
}
